package com.unsafe;

import java.util.*;
import java.util.concurrent.CopyOnWriteArraySet;

/*
* 同理可证
* 1，纯底层的解决方法
* 2，JUC的解决方法
* */
public class SetTest {
    public static void main(String[] args) {
        //hasset 的底层就是hasmap
        Set<String> set = new HashSet<>();
//        Set<String> set = Collections.synchronizedSet(new HashSet<>());
//        Set<String> set = new CopyOnWriteArraySet<>();

        for (int i = 0; i < 30; i++) {
            new Thread(()->{
                set.add(UUID.randomUUID().toString().substring(0,5));
                System.out.println(set);
            },String.valueOf(i)).start();
        }
    }
}
